package com.scsystem.xysc.service.impl;

import com.scsystem.xysc.service.SendssY;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.sms.v20210111.SmsClient;
import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Transactional
@Service
public class SendssYImpl implements SendssY {
    @Override
    public void Send(String phone, String code) {
        try{
            Credential cred = new Credential("AKIDfAUaQ1QZUDgwAG5f9PODtaBXfdPAl144", "umRs4GNLehU7KLPFrCHiz0kHfmcBXfYC");
            HttpProfile httpProfile = new HttpProfile();
            httpProfile.setEndpoint("sms.tencentcloudapi.com");
            ClientProfile clientProfile = new ClientProfile();
            clientProfile.setHttpProfile(httpProfile);
            SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
            SendSmsRequest req = new SendSmsRequest();
            String[] phoneNumberSet1 = {"+86"+phone};
            req.setPhoneNumberSet(phoneNumberSet1);
            req.setSmsSdkAppId("1400810587");
            req.setSignName("天骄刘大炮个人网");
            req.setTemplateId("1759358");
            String[] templateParamSet1 = {code,"3"};
            req.setTemplateParamSet(templateParamSet1);
            SendSmsResponse resp = client.SendSms(req);
            System.out.println(SendSmsResponse.toJsonString(resp));
        } catch (TencentCloudSDKException e) {
            System.out.println(e.toString());
        }
    }

    @Override
    public void Send2(String phone, String code) {
        try{
            Credential cred = new Credential("AKIDfAUaQ1QZUDgwAG5f9PODtaBXfdPAl144", "umRs4GNLehU7KLPFrCHiz0kHfmcBXfYC");
            HttpProfile httpProfile = new HttpProfile();
            httpProfile.setEndpoint("sms.tencentcloudapi.com");
            ClientProfile clientProfile = new ClientProfile();
            clientProfile.setHttpProfile(httpProfile);
            SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
            SendSmsRequest req = new SendSmsRequest();
            String[] phoneNumberSet1 = {"+86"+phone};
            req.setPhoneNumberSet(phoneNumberSet1);
            req.setSmsSdkAppId("1400810587");
            req.setSignName("天骄刘大炮个人网");
            req.setTemplateId("1783086");
            String[] templateParamSet1 = {code,"3"};
            req.setTemplateParamSet(templateParamSet1);
            SendSmsResponse resp = client.SendSms(req);
            System.out.println(SendSmsResponse.toJsonString(resp));
        } catch (TencentCloudSDKException e) {
            System.out.println(e.toString());
        }
    }
}
